import axios from '@/utils/api.request'

// 首页数据
export const homeList = () => {
    return axios.request({
        url: '/api/index/index',
        method: 'post',
    })
}

// user模块
export const accountLog = (data) => {
    return axios.request({
        url: '/api/user/accountLog',
        method: 'post',
        data,
        loading: true
    })
}

// 发送短信验证码
export const getVCode = (mobile) => {
    return axios.request({
        url: '/api/user/getSmsCode',
        method: 'post',
        data: mobile,
        showError: true,
        loading: '获取验证码...',
        showResult: true
    })
}

// 绑定手机
export const bindPhone = (data) => {
    return axios.request({
        url: '/api/user/bindMobile',
        method: 'post',
        data: data,
        showError: true,
        loading: '正在绑定...',
        showResult: true
    })
}

// card模块
export const giftCard = (data) => {
    return axios.request({
        url: '/api/gift/getList',
        method: 'post',
        data
    })
}

export const giftCardDetail = (data) => {
    return axios.request({
        url: '/api/gift/getDetail',
        method: 'post',
        data
    })
}
export const buyGift = (data) => {
    return axios.request({
        url: '/api/cart/buyGift',
        method: 'post',
        data,
        showError: true
    })
}
export const exChange = (data) => {
    console.log('exChange', data );
    return axios.request({
        url: '/api/gift/exchange',
        method: 'post',
        data
    })
}
//订单
export const orderList = (data) => {
    console.log('orderList', data );
    return axios.request({
        url: '/api/order/order_list',
        method: 'post',
        data,
        loading: true
    })
}

export const payCode = (data) => {
    console.log('payCode', data );
    return axios.request({
        url: '/api/payment/getPayCode',
        method: 'post',
        data,
        loading: '处理中...',
        showError: true,
        // showResult: true
    })
}

export const searchWords = (data) => {
    return axios.request({
        url: '/api/goods/getHotWords',
        method: 'post',
        data,
        showError: true,
    })
}

export const searchGoods = (data) => {
    return axios.request({
        url: '/api/goods/search',
        method: 'post',
        data,
        showError: true,
        loading: '搜索中...'
    })
}

export const wallet = (data) => {
    return axios.request({
        url: '/api/user/wallet',
        method: 'post',
        data
    })
}

export const annidou = (data) => {
    return axios.request({
        url: '/api/user/annidou',
        method: 'post',
        data
    })
}

export const goodsCate = (data) => {
    return axios.request({
        url: '/api/goods/categoryList',
        method: 'post',
        data
    })
}

export const goodsList = (data) => {
    return axios.request({
        url: '/api/goods/goodsList',
        method: 'post',
        data,
        loading: true,
        showError: true
    })
}
//地址管理
export const Address = () => {
    return axios.request({
        url: '/api/user/addresssList',
        method: 'get'
    })
}

export const addrDetail = (data) => {
    return axios.request({
        url: '/api/user/addressDetail',
        method: 'post',
        data
    })
}
export const editAddr = (data) => {
    return axios.request({
        url: '/api/user/editAddress',
        method: 'post',
        data,
        showError: true,
        showResult: true
    })
}

export const add2Cart = (data) => {
    return axios.request({
        url: '/api/cart/add',
        method: 'POST',
        data,
        showResult: true,
        showError: true
    })
}

export const cartList = (data) => {
    return axios.request({
        url: '/api/cart/getGoodsList',
        method: 'POST',
        data,
    })
}

export const updateCartNum = (data) => {
    return axios.request({
        url: '/api/cart/updateNum',
        method: 'POST',
        data,
        showError: true
    })
}

export const AsyncUpdateCart = (data) => {
    return axios.request({
        url: '/api/cart/AsyncUpdateCart',
        method: 'POST',
        data,
        showError: true
    })
}

export const goodsInfo = (data) => {
    return axios.request({
        url: '/api/goods/goodsInfo',
        method: 'POST',
        data,
        showError: true,
        loading: true
    })
}

export const recharge = (data) => {
    return axios.request({
        url: '/api/payment/recharge',
        method: 'POST',
        data,
        showError: true,
        loading: '创建订单...'
    })
}

export const getGoodsListByNavId = (data) => {
    return axios.request({
        url: '/api/goods/getGoodsListByNavId',
        method: 'POST',
        data,
        loading: true
    })
}
export const myCollect = (data) => {
    return axios.request({
        url: '/api/goods/mycollect',
        method: 'POST',
        data,
        loading: true
    })
}
export const feedBack = (data) => {
    return axios.request({
        url: '/api/user/feedback',
        method: 'POST',
        data
    })
}
export const recommand = (data) => {
    return axios.request({
        url: '/api/goods/recommand',
        method: 'POST',
        data
    })
}
export const cancelOrder = (data) => {
    return axios.request({
        url: ' /api/order/cancel_order',
        method: 'POST',
        data
    })
}
export const confirmOrder = (data) => {
    return axios.request({
        url: '/api/order/order_confirm',
        method: 'POST',
        data
    })
}

export const cardPay = (data) => {
    return axios.request({
        url: '/api/cart/cart2',
        method: 'get',
        data
    })
}

export const cardSubmit = (data) => {
    return axios.request({
        url: ' /api/cart/cart3',
        method: 'POST',
        data,
        loading: '创建订单...',
        showError: true,
        showResult: true
    })
}

export const order_detail = (data) => {
    return axios.request({
        url: ' /api/order/order_detail',
        method: 'POST',
        data,
        showError: true,
        // showResult: true
    })
}

export const user_sign = (data) => {
    return axios.request({
        url: ' /api/user/user_sign',
        method: 'POST',
        data,
        loading: '正在签到',
        showError: true,
        showResult: true
    })
}

export const wxjsApi = (data) => {
    return axios.request({
        url: ' /api/index/getWechatJsConfig',
        method: 'POST',
        data,
    })
}

// addressConfig
export const addressConfig = (data) => {
    return axios.request({
        url: ' /api/index/region',
        method: 'POST',
        data,
    })
}

// delAddress
export const delAddress = (data) => {
    return axios.request({
        url: ' /api/user/deleteAddress',
        method: 'POST',
        data,
        loading: '正在删除地址',
        showError: true,
        showResult: true
    })
}

// goodsListForFVipPrivate
export const goodsListForFVipPrivate = (data) => {
    return axios.request({
        url: ' /api/goods/goodsListForFVipPrivate',
        method: 'POST',
        data,
        loading: '加载中...',
        showError: true
    })
}

// collect_goods
export const collect_goods = (data) => {
    return axios.request({
        url: ' /api/goods/collect_goods',
        method: 'POST',
        data,
        loading: data.collect ? '正在收藏...' : '取消收藏...',
        showError: true,
        showResult: true
    })
}

// collect_goods
export const activity_goods = (data) => {
    return axios.request({
        url: ' /api/goods/activityGoodsList',
        method: 'POST',
        data,
        showError: true,
    })
}

// collect_goods
export const calcPrice = (data) => {
    return axios.request({
        url: ' /api/cart/cart3',
        method: 'POST',
        data
    })
}
// drawGoods
export const drawGoods = (data) => {
    return axios.request({
        url: ' /api/goods/drawGoods',
        method: 'POST',
        data,
        loading: '正在领取...',
        showError: true,
        showResult: true
    })
}
// pickCoupon
export const pickCoupon = (data) => {
    return axios.request({
        url: ' /api/goods/pickCoupon',
        method: 'POST',
        data,
        loading: '正在领取...',
        showError: true,
        showResult: true
    })
}

// pickCoupon
export const myCoupon = (data) => {
    return axios.request({
        url: ' /api/goods/myCoupon',
        method: 'POST',
        data,
        loading: true,
        showError: true
    })
}

// pickCoupon
export const lastMessage = (data) => {
    return axios.request({
        url: ' /api/index/getLastMessage',
        method: 'POST',
        data,
    })
}

// pickCoupon
export const messageList = (data) => {
    return axios.request({
        url: ' /api/index/getPublicMessage',
        method: 'POST',
        data,
        loading: true,
        showError: true
    })
}


// pickCoupon
export const messageDetail = (data) => {
    return axios.request({
        url: ' /api/index/getPublicMessageDetail',
        method: 'POST',
        data,
        loading: true,
        showError: true
    })
}